#pragma once

#include <QtGui>

class base_autoresize_table
        : public QTableView
{
    Q_OBJECT

public:
    explicit base_autoresize_table(QWidget *parent = nullptr);

    void create_table(int row, int col);
    void clear_table();

    void add_row();
    void del_row();
    void add_col();
    void del_col();

    virtual void auto_resize() = 0;

    QSize sizeHint() const override;
    void resizeEvent(QResizeEvent *e) override;

protected:
    void adjust_parent_size();
    virtual int min_width_for_content () const = 0;
    virtual int min_height_for_content() const = 0;

    int sizeHintForColumn(int column) const override;
    int sizeHintForRow   (int row)    const override;

protected:
    QStandardItemModel *model_;
};

